/************************************************
 * Author       :   XXY
 * Blog         :   https://www.cnblogs.com/jzyl
 * Gitee        :   https://gitee.com/xiaobaichong
 * Email        :   1047185209@QQ.com
 * FileName     :   GenerateScriptPreviewWindow.cs
 * CreateData   :   2023/5/1 10:40:12
 * UnityVersion :   2021.3.20f1c1
 * Description  :   预览脚本窗口
************************************************/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;


namespace Main
{
    /// <summary>
    /// 预览脚本窗口
    /// </summary>
    public class GenerateScriptPreviewWindow : EditorWindow
    {
        static string fileNum = "";
        private static string content { set; get; }
        //[MenuItem("Window/My Window")]
        private static void ShowWindow()
        {
            EditorWindow.GetWindow<GenerateScriptPreviewWindow>("预览窗口");
        }
        public static void ShowWindow(string txt)
        {
            content = txt;
            string[] strs = content.Split("\n");
            fileNum = "";
            for (int i = 1; i <= strs.Length; i++)
            {
                fileNum += i + "\n";
            }
            ShowWindow();
        }


        private Vector2 txtWinSize = new Vector2(100, 100);
        void OnGUI()
        {
            #region 渲染文本 
            txtWinSize = GUILayout.BeginScrollView(txtWinSize, false, true);
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical(GUILayout.Width(10));
            GUILayout.Label(fileNum);
            GUILayout.EndVertical();
            GUILayout.TextArea(content, GUILayout.ExpandHeight(true));
            GUILayout.EndHorizontal();
            GUILayout.EndScrollView();
            #endregion
        }
    }
}
#endif